<template>
  <div class="app-container customer-div">
    <el-tabs v-model="activeName" @tab-click="handleClick">
      <el-tab-pane label="全部人员" name="first">
        <div style="margin-top: 20px">
          <!--搜索-->
          <el-form :inline="true" :model="listQuery" size="mini" label-width="100px">
            <el-form-item label="姓名：">
              <el-input v-model="listQuery.realName"></el-input>
            </el-form-item>
            <el-form-item label="团队名称：">
              <el-input v-model="listQuery.teamName"></el-input>
            </el-form-item>
            <el-form-item label="互助人：">
              <el-input v-model="listQuery.helpUserName"></el-input>
            </el-form-item>
            <el-form-item>
              <el-button
                      @click="handleSearchList()"
                      type="primary">
                查询
              </el-button>
            </el-form-item>
            <el-form-item>
              <el-button
                      @click="showAddPop('add')"
                      type="success">
                新建人员
              </el-button>
            </el-form-item>

          </el-form>
        </div>
        <!--数据列表-->
        <div class="table-container">
          <el-table
                  v-loading="loading"
                  :data="list"
                  border
                  style="width: 100%; margin-top: 20px">
            <el-table-column
                    prop="teamName"
                    label="团队名称"
                    align="center"
                    min-width="100">
            </el-table-column>
            <el-table-column
                    prop="teacherName"
                    label="教练"
                    align="center"
                    min-width="100">
            </el-table-column>
            <el-table-column
                    label="姓名"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.studentName}}</template>
            </el-table-column>
            <el-table-column
                    label="花名"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.anotherName}}</template>
            </el-table-column>
            <el-table-column
                    label="班级职位"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.duty}}</template>
            </el-table-column>
            <el-table-column
                    label="部门"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.departName}}</template>
            </el-table-column>
            <el-table-column
                    label="职位"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.position}}</template>
            </el-table-column>
            <el-table-column
                    label="性别"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.sex}}</template>
            </el-table-column>
            <el-table-column
                    label="手机号"
                    align="center"
                    min-width="150">
              <template slot-scope="scope">{{scope.row.mobile}}</template>
            </el-table-column>
            <el-table-column
                    label="互助人"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.helpUser}}</template>
            </el-table-column>
            <el-table-column
                    label="原始积分"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.oldIntegral}}</template>
            </el-table-column>
            <el-table-column
                    label="当前积分"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.nowIntegral}}</template>
            </el-table-column>
            <el-table-column
                    fixed="right"
                    label="操作"
                    min-width="150"
                    align="center">
              <template slot-scope="scope">
                <el-button type="text" @click="showAddPop('edit',scope.row)">编辑</el-button>
                <el-button type="text" @click="toMxList(scope.row)">积分记录</el-button>
              </template>
            </el-table-column>
          </el-table>
        </div>
        <div class="pagination-container">
          <el-pagination
                  background
                  @size-change="handleSizeChange"
                  @current-change="handleCurrentChange"
                  layout="total, sizes,prev, pager, next,jumper"
                  :current-page.sync="listQuery.pageNum"
                  :page-size="listQuery.pageSize"
                  :page-sizes="[10,15,20]"
                  :total="count">
          </el-pagination>
        </div>
      </el-tab-pane>
      <el-tab-pane label="审批设置" name="second">
        <!--数据列表-->
        <div class="table-container">
          <el-table
                  v-loading="loading2"
                  :data="list2"
                  border
                  style="width: 100%; margin-top: 20px">
            <el-table-column
                    prop="checkType"
                    label="名称"
                    align="center"
                    min-width="150">
            </el-table-column>
            <el-table-column
                    prop="realName"
                    label="姓名"
                    align="center"
                    min-width="100">
            </el-table-column>

            <el-table-column
                    fixed="right"
                    label="操作"
                    min-width="100"
                    align="center">
              <template slot-scope="scope">
                <el-button type="text" @click="showChooseRQ(scope.row)">修改</el-button>
              </template>
            </el-table-column>

          </el-table>
        </div>


      </el-tab-pane>
      <el-tab-pane label="全部积分记录" name="third">
        <div style="margin-top: 20px">
          <!--搜索-->
          <el-form :inline="true" :model="listQuery3" size="mini" label-width="100px">
            <el-form-item label="事件人：">
              <el-select v-model="listQuery3.eventStudentId" clearable>
                <el-option
                        v-for="item in userOptionList"
                        :key="item.studentId"
                        :label="item.studentName"
                        :value="item.studentId">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="类型：">
              <el-select v-model="listQuery3.applyType" clearable>
                  <el-option label="导入" value="导入"></el-option>
                  <el-option label="正常" value="正常"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="申请状态：">
              <el-select v-model="listQuery3.applyState" clearable>
                <el-option label="待一级审核" :value="0"></el-option>
                <el-option label="待二级审核" :value="20"></el-option>
                <el-option label="已审核" :value="30"></el-option>
                <el-option label="已拒绝" :value="10"></el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="申请人：">
              <el-select v-model="listQuery3.applyStudentId" clearable>
                <el-option
                        v-for="item in userOptionList"
                        :key="item.studentId"
                        :label="item.studentName"
                        :value="item.studentId">
                </el-option>
              </el-select>
            </el-form-item>
            <el-form-item label="申请时间：">
              <el-date-picker
                      clearable
                      v-model="listQuery3.applyTime"
                      type="daterange"
                      format="yyyy 年 MM 月 dd 日"
                      value-format="yyyy-MM-dd"
                      range-separator="至"
                      start-placeholder="开始日期"
                      end-placeholder="结束日期">
              </el-date-picker>
            </el-form-item>
            <el-form-item>
              <el-button
                      @click="handleSearchList3()"
                      type="primary">
                查询
              </el-button>
              <el-button
                      v-if="integralExport"
                      @click="downloadExcel">
                导出学员积分
              </el-button>
              <el-button
                      v-if="integralImport"
                      @click="showImport2()">
                导入学员积分
              </el-button>
            </el-form-item>
          </el-form>
        </div>
        <!--数据列表-->
        <div class="table-container">
          <el-table
                  v-loading="loading3"
                  :data="list3"
                  border
                  style="width: 100%; margin-top: 20px">
            <el-table-column
                    label="类型"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.applyType}}</template>
            </el-table-column>
            <el-table-column
                    prop="eventTime"
                    label="发生时间"
                    align="center"
                    min-width="150">
            </el-table-column>
            <el-table-column
                    label="备注"
                    align="center"
                    min-width="150">
              <template slot-scope="scope">{{scope.row.applyContent}}</template>
            </el-table-column>
            <el-table-column
                    label="附件"
                    align="center"
                    min-width="150">
              <template slot-scope="scope">
                <img :src="item" v-for="item in scope.row.applyPicUrl" style="width:50px;height:50px;object-fit: contain;cursor: pointer" @click="showImg(item)"/>
              </template>
            </el-table-column>
            <el-table-column
                    label="申请时间"
                    align="center"
                    min-width="150">
              <template slot-scope="scope">{{scope.row.applyTime}}</template>
            </el-table-column>
            <el-table-column
                    label="申请人"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.createUserName}}</template>
            </el-table-column>
            <el-table-column
                    label="申请状态"
                    align="center"
                    min-width="100">
              <template slot-scope="scope">{{scope.row.applyState | fifapplyState}}</template>
            </el-table-column>
            <el-table-column
                    label="加分明细"
                    min-width="150">
              <template slot-scope="scope">
                <div v-for="item in scope.row.applyDetail">
                    <span>{{item.userRealName}}</span>:<span>{{item.integral}}</span>
                </div>
              </template>
            </el-table-column>

          </el-table>
        </div>
        <div class="pagination-container">
          <el-pagination
                  background
                  @size-change="handleSizeChange3"
                  @current-change="handleCurrentChange3"
                  layout="total, sizes,prev, pager, next,jumper"
                  :current-page.sync="listQuery3.pageNum"
                  :page-size="listQuery3.pageSize"
                  :page-sizes="[10,15,20]"
                  :total="count3">
          </el-pagination>
        </div>
      </el-tab-pane>
    </el-tabs>

    <!--新建编辑人员--->
    <el-dialog
            :close-on-click-modal="false"
            title="新增人员"
            :beforeClose="handleClose"
            :visible.sync="dialogVisible"
            width="350px">
      <el-form :model="addForm" size="mini" label-width="100px" :rules="rules" ref="addForm">
        <el-form-item label="姓名：" prop="userId" v-if="type=='add'">
          <el-select v-model="addForm.userId" filterable placeholder="请选择" clearable style="width:210px">
            <el-option
                    v-for="item in userOptionList2"
                    :key="item.userId"
                    :label="item.userName"
                    :value="item.userId">
            </el-option>
          </el-select>
        </el-form-item>
        <el-form-item label="姓名：" v-else>
            {{addForm.studentName}}
        </el-form-item>
        <el-form-item label="团队名称：" prop="teamName">
            <el-input v-model="addForm.teamName"></el-input>
        </el-form-item>
        <el-form-item label="教练："  prop="teacherName">
          <el-input v-model="addForm.teacherName"></el-input>
        </el-form-item>
        <el-form-item label="花名："  prop="anotherName">
          <el-input v-model="addForm.anotherName"></el-input>
        </el-form-item>
        <el-form-item label="班级职位：" prop="duty">
          <el-input v-model="addForm.duty"></el-input>
        </el-form-item>
        <el-form-item label="互助人："  prop="helpUserIds">
            <el-select v-model="addForm.helpUserIds" filterable placeholder="请选择" clearable multiple style="width:210px">
              <el-option
                      v-for="item in userOptionList2"
                      :key="item.userId"
                      :label="item.userName"
                      :value="item.userId">
              </el-option>
            </el-select>
        </el-form-item>
        <el-form-item label="原始积分：" prop="oldIntegral">
          <el-input v-model="addForm.oldIntegral"></el-input>
        </el-form-item>

      </el-form>
      <span slot="footer" class="dialog-footer">
          <el-button @click="handleClose">取 消</el-button>
          <el-button type="primary" @click="handleConfirm" :loading="btnLoading">确 定</el-button>
      </span>
    </el-dialog>

    <!--审批设置--->
    <el-dialog
            :close-on-click-modal="false"
            title="审批设置"
            :beforeClose="handleClose2"
            :visible.sync="dialogVisible2"
            width="400px">
            <el-form :model="editForm" size="mini" label-width="120px"  ref="editForm">
              <el-form-item label="姓名：" prop="activityName">
                <el-select v-model="editForm.studentId" filterable placeholder="请选择" clearable>
                  <el-option
                          v-for="item in userOptionList"
                          :key="item.studentId"
                          :label="item.studentName"
                          :value="item.studentId">
                  </el-option>
                </el-select>
              </el-form-item>
            </el-form>
      <span slot="footer" class="dialog-footer">
              <el-button @click="handleClose2">取 消</el-button>
              <el-button type="primary" @click="handleConfirm2">确 定</el-button>
          </span>
    </el-dialog>

    <!--积分记录-->
    <el-dialog
            :close-on-click-modal="false"
            title="积分记录"
            :visible.sync="dialogVisible4"
            width="900px">
      <div class="table-container">
        <el-table
                v-loading="loadingpop"
                :data="listpop"
                border
                style="width: 100%; margin-top: 20px">
          <el-table-column
                  prop="integralValue"
                  label="分值"
                  align="center"
                  min-width="100">
          </el-table-column>
          <el-table-column
                  prop="eventTime"
                  label="发生时间"
                  align="center"
                  min-width="150">
          </el-table-column>
          <el-table-column
                  label="备注"
                  align="center"
                  min-width="150">
            <template slot-scope="scope">{{scope.row.applyContent}}</template>
          </el-table-column>
          <el-table-column
                  label="申请人"
                  align="center"
                  min-width="100">
            <template slot-scope="scope">{{scope.row.applyUserName}}</template>
          </el-table-column>

          <el-table-column
                  align="center"
                  prop="operateSource"
                  label="加分时间"
                  min-width="150">
            <template slot-scope="scope">{{scope.row.integralTime }}</template>
          </el-table-column>
        </el-table>
      </div>
      <div style="overflow: hidden">
        <div class="pagination-container">
          <el-pagination
                  background
                  @size-change="handleSizeChangepop"
                  @current-change="handleCurrentChangepop"
                  layout="total, sizes,prev, pager, next,jumper"
                  :current-page.sync="listQuerypop.pageNum"
                  :page-size="listQuerypop.pageSize"
                  :page-sizes="[10,15,20]"
                  :total="countpop">
          </el-pagination>
        </div>
      </div>
    </el-dialog>


    <!--导入-->
    <el-dialog
            :show-close="showClose2"
            :close-on-click-modal="showClose2"
            :close-on-press-escape="showClose2"
            title="学员积分导入"
            :beforeClose="beforeCloseEditPrice2"
            :visible.sync="dialogVisibleImprot2"
            width="500px">
      <div>
        <el-alert
                title="请先按约定好的字段导入学员积分"
                type="warning"
                :closable="false">
        </el-alert>
        <div class="upload-div" style="margin-top:20px">
          <input id="upload" type="file" @change="importfxx(this)" accept=".csv, application/vnd.openxmlformats-officedocument.spreadsheetml.sheet, application/vnd.ms-excel" />
          <el-button type="primary" size="small" :loading="uploadLoading">选择上传文件</el-button>
        </div>
        <div style="margin:20px auto;margin-bottom:0;word-break:break-all;text-align: left;line-height:20px;background: #fef0f0;color:#f56c6c;padding:10px" v-if="msg2!=''">
          <div style="max-height: 90px;overflow: auto;padding:10px"><div v-if="showFial2">添加失败：</div>{{msg2}}</div>
        </div>
      </div>
      <span slot="footer" class="dialog-footer">
          <el-button type="primary" @click="handleEditPriceConfirm2" :loading="EditLoading2">提 交</el-button>
      </span>
    </el-dialog>

    <!--放大图片-->
    <el-dialog
            :visible.sync="dialogVisible5"
            width="800">
      <img :src="cutImg" style="width:100%"/>
    </el-dialog>

  </div>
</template>

<script>
  import { studentList,studentAdd,getUserOption,checkerList,checkerEdit,getOrderUsersList,integralChangeList,integralImport,integralList} from '@/api/partner'
  import {getDeptList,listByDepartMange} from '@/api/management'
  import {formatDate} from '@/utils/date';
  import store from '@/store'
  import { mapGetters } from 'vuex'
  const defaultListQuery = {
      realName:'',
      teamName:'',
      helpUserName:'',
      pageNum:1,
      pageSize:10,
  };

  const defaultListQuery3 = {
      eventStudentId:'',
      "applyStudentId" : '',  //申请人
      "applyTime" : [], //申请时间
      "applyType" : "",
      "applyState" : '', //状态
      "pageNum" : 1,
      "pageSize" : 10
  };

  const defaultListQuery2 = {
    pageNum:1,
    pageSize:10,
  };

  const defaultAddForm = {
      studentId:0,
      userId:'',
      studentName:'',
      anotherName:'', //花名
      teacherName:'',//教练
      teamName:'',//团队
      duty:'',//班级职位
      helpUserIds:[],//互助人
      oldIntegral:''
  };

  const defaultEditForm = {
      id:0,
      studentId:'',
  };

  const defaultForm = {
    activityName:'',
    itemList:[],
    logList:[]
  };

  export default {
    name: "index",
    data(){
      const otherEvaluateTime = (rule, value, callback)=> {
        if (value.length == 0) {
          callback(new Error('请选择投票时间'))
        }else if( this.addForm.selfEvaluateTime.length > 0 && (new Date(value[0]).getTime() <= new Date(this.addForm.selfEvaluateTime[1]).getTime())){
          callback(new Error('投票时间需大于自评时间'))
        }else{
          callback()
        }
      };
      return{
        roles:store.getters.roles ? store.getters.roles : [],
        listQuery:JSON.parse(JSON.stringify(defaultListQuery)),
        list:[],
        count:0,
        loading:false,

        list2:[],
        count2:0,
        loading2:false,

        listpop:[],
        listQuerypop:JSON.parse(JSON.stringify(defaultListQuery2)),
        countpop:0,
        loadingpop:false,
        dialogVisible4:false,
        title4:'',
        userOptionList:[],
        activeName:'first',
        addForm:JSON.parse(JSON.stringify(defaultAddForm)),
        dialogVisible:false,

        rules:{
            userId:[{required: true, trigger: 'change' ,message: '此项必填'}],
            anotherName:[{required: true, trigger: 'blur' ,message: '此项必填'}],
            teacherName:[{required: true, trigger: 'blur' ,message: '此项必填'}],
            teamName:[{required: true, trigger: 'blur' ,message: '此项必填'}],
            duty:[{required: true, trigger: 'blur' ,message: '此项必填'}],
            helpUserIds:[{required: true, trigger: 'change' ,message: '此项必填'}],
            oldIntegral:[{required: true, trigger: 'blur' ,message: '此项必填'}],
        },
        btnLoading:false,
        dialogVisible2:false,
        editForm:JSON.parse(JSON.stringify(defaultEditForm)),
        userOptionList2:[],
        type:'',

        showClose2:true,
        dialogVisibleImprot2:false,//批量导入弹窗
        EditLoading2:false,//批量导入提交按钮loadin
        showFial2:false,//批量导入失败
        msg2:'',//上传文件信息
        uploadLoading:false,
        da:[],
        file:null,


        listQuery3:JSON.parse(JSON.stringify(defaultListQuery3)),
        list3:[],
        count3:0,
        loading3:false,
        cutImg:'',
        dialogVisible5:false,
      }
    },
    computed: {
      ...mapGetters([
        'name',
        'mobile',
        'userId'
      ]),
      integralImport() {
          if (this.roles.indexOf("integralImport") != -1) {
              return true
          } else {
              return false
          }
      },
      integralExport() {
          if (this.roles.indexOf("integralExport") != -1) {
              return true
          } else {
              return false
          }
      },
    },
    created() {
      this.getList();
      this.getList2();
      this.getList3();
      this.getUserOptionList();
      this.getUserOptionList2();
    },

    filters: {
      fifState(val) {
        if(val == 0 ){
          return '未开始'
        }else if(val == 10){
          return '已取消'
        }else if(val == 15){
          return '自评中'
        }else if(val == 20){
          return '进行中'
        }else if(val == 30){
          return '已结束'
        }
      },

      fifapplyState(val){
          if(val == 0){
              return '待一级审核'
          }else if(val == 10){
              return '已拒绝'
          }else if(val == 20){
              return '待二级审核'
          }else if(val == 30){
              return '已审核'
          }
      }
    },
    methods:{
        showImg(item){
            this.cutImg = item;
            this.dialogVisible5 = true;
        },
        //下载excle
        downloadExcel(){
            let data = JSON.parse(JSON.stringify(this.listQuery3));
            data.isExport = 1;
            integralList(data).then((res)=>{
                require.ensure([], () => {
                    const { export_json_to_excel } = require('sheet/Export2Excel');
                    const tHeader = res.title;
                    const filterVal = res.columns;
                    const list = res.list;
                    const data = this.formatJson(filterVal, list);
                    export_json_to_excel(tHeader, data, res.fileName);
                })
            })
        },

        //下载表格数据格式化
        formatJson(filterVal, jsonData) {
            return jsonData.map(v => filterVal.map(j => v[j]))
        },

        //导入excel
        importfxx(obj) {
            let _this = this;
            this.uploadLoading = true;
            let inputDOM = this.$refs.inputer;
            // 通过DOM取文件数据
            this.file = event.currentTarget.files[0];
            var rABS = false; //是否将文件读取为二进制字符串
            var f = this.file;
            var reader = new FileReader();
            //if (!FileReader.prototype.readAsBinaryString) {
            FileReader.prototype.readAsBinaryString = function(f) {
                var binary = "";
                var rABS = false; //是否将文件读取为二进制字符串
                var pt = this;
                var wb; //读取完成的数据
                var outdata;
                var reader = new FileReader();
                reader.onload = function(e) {
                    var bytes = new Uint8Array(reader.result);
                    var length = bytes.byteLength;
                    for(var i = 0; i < length; i++) {
                        binary += String.fromCharCode(bytes[i]);
                    }
                    var XLSX = require('xlsx');
                    if(rABS) {
                        wb = XLSX.read(btoa(fixdata(binary)), { //手动转化
                            type: 'base64'
                        });
                    } else {
                        wb = XLSX.read(binary, {
                            type: 'binary'
                        });
                    }
                    outdata = XLSX.utils.sheet_to_json(wb.Sheets[wb.SheetNames[0]]);//outdata就是你想要的东西
                    // if (outdata.length  > 200){
                    //   _this.$message({
                    //     message: '最大上传200条',
                    //     type: 'error'
                    //   });
                    //   var test = document.getElementById('upload');
                    //   test.value = '';
                    //   return false;
                    // }
                    _this.da = [...outdata];
                    console.log("da",_this.da)
                    let arr = [];

                    let para = {
                        withList: arr
                    };
                    _this.$message({
                        message: '上传成功，请点击提交',
                        type: 'success'
                    });
                    _this.uploadLoading = false;
                };
                reader.readAsArrayBuffer(f);
            };
            if(rABS) {
                reader.readAsArrayBuffer(f);
            } else {
                reader.readAsBinaryString(f);
            }
        },

        //显示导入弹窗
        showImport2(){
            this.showFial2 = false;
            this.EditLoading2 = false;
            this.uploadLoading = false;
            this.msg2 = '';
            this.dialogVisibleImprot2 = true;
        },
        //关闭导入弹窗
        beforeCloseEditPrice2(){
            $("#upload").val('');
            this.da = [];
            this.msg2 = '';
            this.dialogVisibleImprot2 = false;
        },


        //提交导入
        handleEditPriceConfirm2(){
            if (this.da.length == 0){
                this.$message({
                    message: '上传数据为空',
                    type: 'warning'
                });
                return false;
            }
            this.msg2 = '后台处理中，请耐心等待……';
            this.showFial2 = false;
            this.EditLoading2 = true;
            this.showClose2 = false;
            integralImport({list:this.da}).then((res)=>{
                this.$message({
                    message: '修改成功',
                    type: 'success'
                });
                this.msg2 = '修改成功';
                this.EditLoading2 = false;
                this.dialogVisible2 = false;
                this.showClose2 = true;
                this.da = [];
                this.dialogVisibleImprot2 = false;
                $("#upload").val('');
                this.getList3();
            }).catch((err)=>{
                this.msg2 = err.msg;
                this.showFial2 = true;
                this.EditLoading2 = false;
                $("#upload").val('');
                this.showClose2 = true;
            })
        },



      //查看积分记录
      toMxList(item){
          this.listQuerypop.userId = item.userId;
          this.handleSearchListpop();
          this.dialogVisible4 = true;
      },

      handleSearchListpop(){
        this.listQuerypop.pageNum = 1;
        this.getListpop();
      },

      //获取积分记录列表
      getListpop(){
        this.loadingpop = true;
        let data = JSON.parse(JSON.stringify(this.listQuerypop));
        integralChangeList(data).then((res)=>{
          this.listpop = res.list;
          this.countpop = res.count;
          this.loadingpop = false;
        }).catch(()=>{
          this.loadingpop = false;
        })
      },

      handleSizeChangepop(val){
        this.listQuerypop.pageNum = 1;
        this.listQuerypop.pageSize = val;
        this.getListpop();
      },
      handleCurrentChangepop(val){
        this.listQuerypop.pageNum = val;
        this.getListpop();
      },


      //获取学员下拉选项
      getUserOptionList(){
        studentList({pageNum:1,pageSize:200}).then((res)=>{
          this.userOptionList = res.list;
        })
      },


        //获取员工下拉选项
        getUserOptionList2(){
            getOrderUsersList({pageNum:1,pageSize:200}).then((res)=>{
                this.userOptionList2 = res;
            })
        },


      //显示审批弹窗
      showChooseRQ(item){
        this.dialogVisible2 = true;
        this.editForm.id = item.id;
        this.editForm.studentId = item.studentId;
      },

      //关闭审批弹窗
      handleClose2(){
        this.dialogVisible2 = false;
      },

      //确认审批弹窗
      handleConfirm2(){
        this.dialogVisible2 = false;
        let data = {};
        data.id = this.editForm.id;
        data.studentId = this.editForm.studentId;
        checkerEdit(data).then(()=>{
            this.getList2()
        })
      },

      handleClick(){

      },

      //显示新建/编辑人员弹窗
      showAddPop(type,item){
        this.dialogVisible = true;
        this.type = type;
        if(type == 'add'){
            this.addForm = JSON.parse(JSON.stringify(defaultAddForm))
        }else{
             this.addForm.studentId = item.studentId;
             this.addForm.studentName = item.studentName;
             this.addForm.userId = item.userId;
             this.addForm.anotherName = item.anotherName;
             this.addForm.teacherName = item.teacherName;
             this.addForm.teamName = item.teamName;
             this.addForm.duty = item.duty;
             this.addForm.helpUserIds = [];
             item.helpUserIds.forEach((el)=>{
                 this.addForm.helpUserIds.push(parseFloat(el))
             });
             this.addForm.oldIntegral = item.oldIntegral;
        }
      },

      //关闭新建/编辑人员
      handleClose(){
        this.dialogVisible = false;
      },

      //提交新建/编辑人员
      handleConfirm(){
        this.$refs.addForm.validate((valid) => {
          if (valid) {
            studentAdd(this.addForm).then((res)=>{
              this.$message({
                type: 'success',
                message: '操作成功!'
              });
              this.btnLoading = false;
              this.getList();
              this.handleClose();
            }).catch(()=>{
              this.btnLoading = false
            })
          }
        })
      },

      handleSearchList(){
        this.listQuery.pageNum = 1;
        this.getList();
      },

      //获取活动列表
      getList(){
        this.loading = true;
        let data = JSON.parse(JSON.stringify(this.listQuery));
        studentList(data).then((res)=>{
          this.list = res.list;
          this.count = res.count;
          this.loading = false;
        }).catch(()=>{
          this.loading = false;
        })
      },

      handleSizeChange(val){
        this.listQuery.pageNum = 1;
        this.listQuery.pageSize = val;
        this.getList();
      },
      handleCurrentChange(val){
        this.listQuery.pageNum = val;
        this.getList();
      },


      handleSearchList2(){
        this.listQuery2.pageNum = 1;
        this.getList2();
      },

      //获取活动列表
      getList2(){
        this.loading2 = true;
        checkerList().then((res)=>{
          this.list2 = res;
          this.loading2 = false;
        }).catch(()=>{
          this.loading2 = false;
        })
      },

      handleSizeChange2(val){
        this.listQuery2.pageNum = 1;
        this.listQuery2.pageSize = val;
        this.getList2();
      },
      handleCurrentChange2(val){
        this.listQuery2.pageNum = val;
        this.getList2();
      },


        handleSearchList3(){
            this.listQuery3.pageNum = 1;
            this.getList3();
        },

        //获取全部列表
        getList3(){
            this.loading3 = true;
            let data = JSON.parse(JSON.stringify(this.listQuery3));
            integralList(data).then((res)=>{
                this.list3 = res.list;
                this.count3 = res.count;
                this.loading3 = false;
            }).catch(()=>{
                this.loading3 = false;
            })
        },

        handleSizeChange3(val){
            this.listQuery3.pageNum = 1;
            this.listQuery3.pageSize = val;
            this.getList3();
        },
        handleCurrentChange3(val){
            this.listQuery3.pageNum = val;
            this.getList3();
        },
    },
  }
</script>

<style scoped lang="scss">
  .upload-div{
    text-align: center;
    position:relative;
    #upload{

      opacity: 0;
      position: absolute;
      z-index: 1;
      width:154px;
      height:40px
    }
  }
</style>
